package com.waghost.bridalgown.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.waghost.bridalgown.dao.BridalGownDao;
import com.waghost.bridalgown.dao.CategoryDao;
import com.waghost.bridalgown.entity.BridalGown;
import com.waghost.bridalgown.entity.Category;
import com.waghost.bridalgown.entity.Result;
import com.waghost.bridalgown.service.BridalGownService;
import com.waghost.bridalgown.service.CategoryService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@AllArgsConstructor
@Service
public class ICategoryService implements CategoryService {

    private CategoryDao categoryDao;


    @Override
    public Result list() {
        return Result.success(categoryDao.selectList(new QueryWrapper<Category>().orderByDesc("od")));
    }

    @Override
    public Result getId(Integer id) {
        return Result.success(categoryDao.selectById(id));
    }

    @Override
    public Result add(Category category) {
        return Result.toAjax(categoryDao.insert(category), "添加成功", "添加错误");
    }

    @Override
    public Result update(Category category) {
        return Result.toAjax(categoryDao.updateById(category), "修改成功", "修改错误");
    }

    @Override
    public Result delete(Integer id) {
        return Result.toAjax(categoryDao.deleteById(id), "删除成功", "删除错误");
    }

}
